{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import  schedule\n",
    "import time\n",
    "import threading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hi\n"
     ]
    }
   ],
   "source": [
    "def job( message=\"hello\"):\n",
    "    print message\n",
    "class j:\n",
    "    def __init__(self):\n",
    "        pass\n",
    "    def job1(self,say=\"hi\"):\n",
    "        print say\n",
    "cat=j()\n",
    "cat.job1()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "start\n",
      "hi\n",
      "job1\n",
      "hi\n",
      "job1\n",
      "hi\n",
      "job1\n",
      "hi\n",
      "job1\n",
      "hi\n",
      "job1\n",
      "hi\n",
      "job1\n"
     ]
    }
   ],
   "source": [
    "schedule.every(1).seconds.do(job,\"hi\")\n",
    "schedule.every(1).seconds.do(cat.job1,\"job1\")\n",
    "# schedule.every(10).minutes.do(job)\n",
    "# schedule.every(5).to(10).days.do(job)\n",
    "# schedule.every().hour.do(job, message='things')\n",
    "# schedule.every().day.at(\"10:30\").do(job)\n",
    "def JOB():\n",
    "    print \"start\"\n",
    "    while 1:\n",
    "        schedule.run_pending()\n",
    "        time.sleep(1)\n",
    "dojob=threading.Thread(target=JOB ).start()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'asfg gasd_2155'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "from concurrent.futures import ThreadPoolExecutor\n",
    "def sayHello(say=\"hello\"):\n",
    "    print(time.time())\n",
    "    time.sleep(10)\n",
    "    print(say)\n",
    "thread=ThreadPoolExecutor(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1535278128.56\n",
      "1535278128.58\n",
      "1535278128.59\n",
      "hello\n",
      "1535278138.58\n",
      "hello\n",
      "1535278138.59\n",
      "hello\n",
      "hello\n",
      "hello\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    thread.submit(sayHello)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
